<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>项目管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script type="text/javascript">
        var grid = null;
        var searchOrgTree = null;
        $(function () {
            initOrgTree();
            $("#ligergrid1").ligerGrid({
                url: '<%=path%>/infside/infWarrantProject/initInfWarrantProjectList.do',
                method : 'get',
                columns: [
                    { display: '所属事业部', name: 'orgNo', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '所属公司', name: 'provincialCompany', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '项目名称', name: 'projectName', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '客户名称', name: 'customerName', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '客户类型', name: 'customerType', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '业务类型', name: 'businessType', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '合同总价', name: 'contractPaymentdou', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '项目性质', name: 'projectNature', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '发送状态', name: 'statusNm', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '返回信息', name: 'message', minWidth: 300, align: 'center', enabledSort:true},
                    {
                        display: '操作',minWidth: 100,align: 'center',
                        render: function (rowdata, rowindex, value){
                            var h1='<a href="javascript:void(0);" onclick="searchProjectDetail(\''+rowdata.projectId+'\')">明细</a>';
                            var h2='<span style="color:#C9C9C9;">发送</span>';
                            if(rowdata.status!="success"){
                                h2='<a href="javascript:void(0);" onclick="projectApply(\''+rowdata.projectId+'\')">发送</a>';
                            }
                            return h1+'&nbsp;&nbsp;&nbsp;&nbsp;'+h2;
                        }
                    }
                ],
                pageSize:10,
                root:'rows',
                record:'total',
                hideLoadButton : true,
                width: '100%',
                height: '100%',
                heightDiff:-2,
                //checkbox:true,
                rownumbers:true
            });
            grid = liger.get("ligergrid1");
            grid.setHeight(100);
            $("#searchBar").ligerForm();
            $("#searchBtn").click(function(event) {
                var form = new liger.get("searchBar");
                var data = form.getData();
                console.log(data);
                for (name in data){
                    grid.setParm(name,data[name]);
                };
                grid.reload();
            });
            $("#clearBtn").click(function(event) {
                clearLigerForm("searchBar");
            });
        });
        //明细
        function searchProjectDetail(_projectId){
            if (parent.pageInTab) {
                parent.pageInApp.projectid=_projectId;
                parent.pageInTab.selectTabItem('WarrantPay');
                parent.pageInTab.reload('WarrantPay');
            }
        }
        //发送项目
        function projectApply(_projectId){
            $.ligerDialog.confirm("是否确认发送?", function (flag) {
                if(flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType:'json',
                    data:'projectId='+_projectId,
                    url: '<%=path%>/infside/infWarrantProject/projectApply.do',
                    beforeSend: function(){
                        wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                    },
                    success:function(msg){
                        wait_dialog.close();
                        if(msg.success == 1){
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                            grid.reload();
                        }else{
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        }
        //初始化组织架构
        function initOrgTree(){
            searchOrgTree = $("#provincialCompany").ligerComboBox({
                selectBoxWidth: 240,
                selectBoxHeight: 150,
                valueField:'orgCd',
                textField:'orgDispNm',
                //限制只能选叶节点，父节点不能点击
                treeLeafOnly: false,
                tree: {
                    ajaxType: 'get',
                    idFieldName:'orgCd',
                    textFieldName: 'orgDispNm',
                    checkbox: false,
                    parentIcon: "none",
                    childIcon: "none",
                },
                onSelected: function (){}
            });
            $.ajax({
                type: 'get',
                dataType:'json',
                data: "",
                url: '<%=path%>/infside/infWarrantProject/searchOrgTree.do',
                success:function(msg){
                    if(msg.success == 1){
                        searchOrgTree.treeManager.setData(msg.data);
                        searchOrgTree.clear();
                    }else{
                        $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                    }
                }
            });

        }
    </script>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">项目名称</div>
                    <div class="field">
                        <input name="projectName" id="projectName" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="customerName" id="customerName" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">所属公司</div>
                    <div class="field">
                        <input name="provincialCompany" id="provincialCompany" type="text" value="" placeholder="请选择"  ltype="combobox">
                    </div>
                    <div style="display: none">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">状态</div>
                    <div class="field">
                        <select name="status"  id="status"  disabled="disabled">
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${statuslist}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">项目类型</div>
                    <div class="field">
                        <select name="projectType"  id="projectType"  disabled="disabled">
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${prjtypelist}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
                    <span id="clearBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_19"></i>清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</body>
</html>
